package main

import (
	"fmt"
	"strings"
	"time"
)

type Task struct {
	Name string
}

func sendWork(t chan *Task) {
	t <- &Task{"zhangsan"}
	t <- &Task{"lisi"}
	t <- &Task{"wangwu"}
}

func worker(in, out chan *Task) {
	for {
		t := <-in
		process(t)
		out <- t
	}
}

func process(task *Task) {
	task.Name = strings.ToUpper(task.Name)
}

func consumeWork(t chan *Task) {
	for {
		if len(t) > 0 {
			fmt.Println(<-t)
		}
		return
	}
}

func main() {
	pending, done := make(chan *Task), make(chan *Task)
	go sendWork(pending)
	go worker(pending, done)
	consumeWork(done)
	time.Sleep(1e9)
}
